package com.jbl.te.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jbl.te.entity.Department;
import com.jbl.te.entity.Teacher;
import com.jbl.te.entity.vo.DepartmentQuery;
import com.jbl.te.mapper.DepartmentMapper;
import com.jbl.te.service.DepartmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jbl
 * @since 2020-12-11
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {

    @Override
    public void pageQuery(Page<Department> pageParam, DepartmentQuery departmentQuery) {
        if (departmentQuery == null) {
            this.page(pageParam,null);
            return;
        }
        String name = departmentQuery.getName();
        String collegeId = departmentQuery.getCollegeId();
        QueryWrapper<Department> wrapper = new QueryWrapper<>();

        if(!StringUtils.isEmpty(name)) {
            wrapper.like("name",name);
        }
        if(!StringUtils.isEmpty(collegeId)) {
            wrapper.eq("college_id",collegeId);
        }

        this.page(pageParam,wrapper);
    }
}
